package de.listrong.da.ontology;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;

/* container for word individuals*/
public class WordList extends LinkedList<WordIndividual> {

	private static final long serialVersionUID = -7747920157865780964L;
	private boolean hasRelation = false;

	public boolean isHasRelation() {
		return hasRelation;
	}

	public void setHasRelation(boolean hasRelation) {
		this.hasRelation = hasRelation;
	}

	@Override
	public boolean add(WordIndividual e) {
		boolean result = super.add(e);
		if (e.getType() == "oProperty")
			this.hasRelation = true;
		return result;
	}

	@Override
	public String toString() {
		Iterator<WordIndividual> iter = iterator();
		if (!iter.hasNext())
			return "[]";
		StringBuilder sb = new StringBuilder();
		while (iter.hasNext()) {
			WordIndividual sentenceIndi = iter.next();
			sb.append(sentenceIndi + "\n");
		}
		return sb.toString();
	}

	public void sortByOffset() {
		Collections.sort(this);
	}

}
